/**
 * Description:
 * Class Name:ForeachTest
 * Date:2022/2/26 10:58
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第8章_Java集合._8_2_Java11增强的Collection和Iterator接口._8_2_4_使用foreach循环遍历集合元素;

import java.util.HashSet;

public class ForeachTest {
    public static void main(String[] args) {
        // 创建一个集合
        var books = new HashSet();
        books.add("book1");
        books.add("book2");
        books.add("book3");

        var s = new String[5];
        for (var book :
                books) {
            // 此处的book变量也不是集合元素本身
            book = (String) book;
            System.out.println(book);
        }
    }
}
